package 笔试强训;

import java.util.Scanner;

public class _0416T2 {
    public static void main(String[] args) {
        int[] costs = new int[1000000];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if(n==1) {
            int res = scanner.nextInt();
            System.out.println(res);
        }
        for (int i = 0; i < n; i++) {
            costs[i] = scanner.nextInt();
        }
        int[] dp = new int[1000000];//dp数组表示到当前阶梯需要花费的最小cost
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i <= n; i++) {
            dp[i] = Math.min(dp[i-1]+costs[i-1],dp[i-2]+costs[i-2]);
        }
        System.out.println(dp[n]);
    }
}
